<cfparam name="Fund_ID" type="integer" />

<cfscript>
	fundGateway = new assets.calgrants.com.gateway.FundGateway();
	fund = fundGateway.get(Fund_ID = Fund_ID);
</cfscript>

<cfif fund.getFund_ID() gt 0>

	<cfscript>
		fundWorkshopGateway = new assets.calgrants.com.gateway.FundWorkshopGateway();
		fundWorkshops = fundWorkshopGateway.query(Fund_ID = fund.getFund_ID());
		organizationGateway = new assets.calgrants.com.gateway.OrganizationGateway();
		organization = organizationGateway.get(Organization_ID = fund.getOrganization_ID());
		userGateway = new assets.calgrants.com.gateway.UserGateway();
		requestedBy = userGateway.get(User_ID = fund.getRequested_By_ID());
		if (fund.getApproved()) {
			approvedBy = userGateway.get(User_ID = fund.getApproved_By_ID());
		}
	</cfscript>
	
	<style type="text/css">
		.printable {
			max-width: 800px;
			margin-top: 20px;
			margin-left: 20px;
		}
		h1, h2, h3, h4, h5 {
			color: black;
		}
	</style>

	<cfoutput>
	
		<div class="printable">
		
			<img src="common/images/Cash_for_College_logo.gif" width="204" height="54" style="margin-bottom: 15px;">
		
			<h2>Cash for College Site Support Funds Invoice</h2>
			
			<cfif fund.getApproved() eq 0>
				<div class="alert alert-error">
					<button type="button" class="close" data-dismiss="alert">&times;</button>
					This Site Support Funds Request is not approved
				</div>
			</cfif>
			
			<h4>Invoice ###Year(Now())#-#fund.getFund_ID()#</h4>

			<h4>#DateFormat(now(), "mmmm d, yyyy")#</h4>

			<div class="clearfix">
			
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr valign="top">
						<td width="50%">
						
							<h4>Payee Mailing Address</h4>

							#fund.getPayee_Organization()#<br>
							<cfif Len(Trim(fund.getPayee_Department())) gt 0>
								#fund.getPayee_Department()#<br>
							</cfif>
							Attention: #fund.getPayee_First_Name()# #fund.getPayee_Last_Name()#<br>
							#fund.getPayee_Address()#<br>
							#Trim(fund.getPayee_City())#, CA #fund.getPayee_Zip_Code()#<br>
							#fund.getPayee_Phone()#<br>
							#fund.getPayee_Email()#<br>
							<cfif (IsUserInRole("Super User") or IsUserInRole("Regional Admin")) and len(fund.getPayee_Tax_ID())>
								Tax ID: #fund.getPayee_Tax_ID()#<br>
							</cfif>
							
						</td>
						<td width="50%">
						
							<h4>Requested By/Organization</h4>
							
							#requestedBy.getFirst_Name()# #requestedBy.getLast_Name()#<br>
							#organization.getOrganization()#<br>
							#organization.getAddress()#<br>
							#organization.getCity()#, CA #organization.getZip_Code()#<br>
							#requestedBy.getPhone()#<cfif Len(Trim(requestedBy.getExtension())) gt 0>&nbsp;x&nbsp;#requestedBy.getExtension()#</cfif><br>
							#requestedBy.getEmail()#<br>
						
						</td>
					</tr>
				</table>
			
			</div>
			
			<hr size="1" />
			
			<h4>Workshops</h4>
			
			<div class="clearfix">
			
				<table class="table table-bordered">
					<thead>
						<tr>
							<th>Workshop</th>
							<th style="width: 110px;">Fund Amount</th>
						</tr>
					</thead>
					<tbody>
					<cfset totalFundAmount = 0 />
					<cfloop query="fundWorkshops">
						<tr>
							<td>
								#Site#,	#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#
							</td>
							<td style="text-align: right;">#DollarFormat(Fund_Amount)#</td>
						</tr>
						<cfset totalFundAmount = totalFundAmount + Fund_Amount />
					</cfloop>
					</tbody>
					<tfoot>
						<tr>
							<th>Total</th>
							<th style="text-align: right;">#DollarFormat(totalFundAmount)#</th>
						</tr>
					</tfoot>
				</table>
			
			</div>

		</div>
		
	</cfoutput>
	
<cfelse>

	<div class="alert alert-info notFound">Site Support Fund Request not found</p>
	
</cfif>
